package com.pan.test.service;

import com.pan.test.entity.dto.SessionWebUserDto;
import com.pan.test.entity.dto.UploadResultDto;
import com.pan.test.entity.po.FileInfo;
import com.pan.test.entity.query.FileInfoQuery;
import com.pan.test.entity.vo.PaginationResultVO;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;


/**
 * 文件信息 业务接口
 */
public interface FileInfoService {

    /**
     * 根据条件查询列表
     */
    List<FileInfo> findListByParam(FileInfoQuery param);

    /**
     * 根据条件查询列表
     */
    Integer findCountByParam(FileInfoQuery param);

    /**
     * 分页查询
     */
    PaginationResultVO<FileInfo> findListByPage(FileInfoQuery param);

    /**
     * 新增
     */
    Integer add(FileInfo bean);

    /**
     * 批量新增
     */
    Integer addBatch(List<FileInfo> listBean);

    /**
     * 批量新增/修改
     */
    Integer addOrUpdateBatch(List<FileInfo> listBean);

    /**
     * 根据FileIdAndUserId查询对象
     */
    FileInfo getFileInfoByFileIdAndUserId(String fileId, String userId);


    /**
     * 根据FileIdAndUserId修改
     */
    Integer updateFileInfoByFileIdAndUserId(FileInfo bean, String fileId, String userId);


    /**
     * 根据FileIdAndUserId删除
     */
    Integer deleteFileInfoByFileIdAndUserId(String fileId, String userId);

    UploadResultDto uploadFile(SessionWebUserDto webUserDto, String fileId, MultipartFile file, String fileName, String filePid, String fileMd5, Integer chunkIndex,
                               Integer chunks);

    FileInfo rename(String fileId, String userId, String fileName);

    FileInfo newFolder(String filePid, String userId, String folderName);

    void changeFileFolder(String fileIds, String filePid, String userId);

    void removeFile2RecycleBatch(String userId, String fileIds);

    void recoverFileBatch(String userId, String fileIds);

    void delFileBatch(String userId, String fileIds, Boolean adminOp);

    void checkRootFilePid(String rootFilePid, String userId, String fileId);

    void saveShare(String shareRootFilePid, String shareFileIds, String myFolderId, String shareUserId, String cureentUserId);

    Long getUserUseSpace(@Param("userId") String userId);

    void deleteFileByUserId(@Param("userId") String userId);

    /**
     * 根据条件查询数量
     */
    Integer findCount(FileInfoQuery param);

    /**
     * 获取总文件大小
     */
    Long getTotalFileSize();

    /**
     * 获取文件类型分布
     */
    List<Map<String, Object>> getFileTypeDistribution();

    /**
     * 获取存储使用趋势
     */
    List<Map<String, Object>> getStorageTrend(Integer days);

    /**
     * 搜索文件
     */
    List<Map<String, Object>> searchFiles(String keyword);

    /**
     * 批量删除文件
     */
    void batchDeleteFiles(List<String> fileIds);

    /**
     * 获取文件下载信息
     */
    Map<String, Object> getFileDownloadInfo(String fileId);
}